package com.tang.portal.controller.admin.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tang.framework.core.controller.BaseController;
import com.tang.framework.core.domain.HttpResult;

import com.tang.common.model.req.ReqId;
import com.tang.portal.facade.admin.sys.SysDictTypeFacade;
import com.tang.service.admin.model.req.ReqSysDictType;
import com.tang.service.admin.model.req.ReqSysDictTypeAdd;
import com.tang.service.admin.model.res.ResSysDictTypeTableItem;
import com.tang.service.admin.model.res.ResSysDictTypeDetail;
import com.tang.common.model.req.ReqIds;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import lombok.SneakyThrows;
import jakarta.annotation.Resource;

/**
 * @author tang jun liang
 * @Date ${gen.dateTime}
 */
@Tag(name = "数据字典")
@RestController
@RequestMapping("/sys/dict/type")
public class SysDictTypeController extends BaseController {

    @Resource
    private SysDictTypeFacade sysDictTypeFacade;


    @Operation(summary = "删除字典类型表")
    @PostMapping("/remove")
    public HttpResult<String> remove(@RequestBody ReqIds ids) {
        return sysDictTypeFacade.remove(ids, getCurrLoginUser());
    }

    @Operation(summary = "字典类型表详情")
    @PostMapping("/detail")
    public HttpResult<ResSysDictTypeDetail> detail(@RequestBody ReqId id) {
        return sysDictTypeFacade.detail(id, getCurrLoginUser());
    }

    @Operation(summary = "字典类型表详情")
    @PostMapping("/list")
    public HttpResult<IPage<ResSysDictTypeTableItem>> list(@RequestBody ReqSysDictType reqSysDictType) {
        return sysDictTypeFacade.list(reqSysDictType, getCurrLoginUser());
    }


    @Operation(summary = "新增字典类型表")
    @PostMapping("/add")
    public HttpResult<String> add(@RequestBody ReqSysDictTypeAdd sysDictTypeAdd){
        return sysDictTypeFacade.add(sysDictTypeAdd);
    }

    @Operation(summary = "编辑字典类型表")
    @PostMapping("/update")
    public HttpResult<String> update(@RequestBody ReqSysDictTypeAdd sysDictTypeAdd){
        return sysDictTypeFacade.update(sysDictTypeAdd);
    }


    @Operation(summary = "导出excel-字典类型表")
    @PostMapping("/export")
    public void export(@RequestBody ReqIds ids){
        sysDictTypeFacade.export(ids, httpServletResponse);
    }

    @Operation(summary = "导出excel-模版")
    @PostMapping("/export/template")
    public void exportTemplate(){
        sysDictTypeFacade.exportTemplate(httpServletResponse);
    }

    @SneakyThrows
    @Operation(summary = "导入excel-字典类型表")
    @PostMapping("/importExcel")
    public HttpResult<String> importExcel(MultipartFile file){
        return sysDictTypeFacade.importExcel(file);
    }


}
